<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
     <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css"
	href="<c:url value="/css/themes/default/easyui.css"/>">
<link rel="stylesheet" type="text/css"
	href="<c:url value="/css/themes/icon.css"/>">
<script type="text/javascript" src="<c:url value="/js/jquery.min.js"/>"></script>
<script type="text/javascript"
	src="<c:url value="/js/jquery.easyui.min.js"/>"></script>
<script type="text/javascript"
	src="<c:url value="/js/easyui-lang-zh_CN.js"/>"></script>
<title>蒋路的开始收费页面</title>
</head>
<body>
	<style>
		#bgcharge_btn{
			margin-top:-5px;
			margin-left:-10px;
			margin-right:-10px;
			height:40px;
			background-color:#d2e9ff;
			border-top-right-radius:12px;
			border-top-left-radius:12px;
			border-bottom-right-radius:12px;
			border-bottom-left-radius:12px;
		}
	</style>
	<script type="text/javascript"> 
	
		$.extend($.fn.validatebox.defaults.rules, {
			ChackIc: {
		        validator: function(value){
		        	$.ajax({
		                type: "Post",
		                url: "to_icnumtoic",
		                data: {icnum:value},
		                success: function (data) { 
		                	var date = new Date();		
		        			var y = date.getFullYear();  
		        			var m = date.getMonth() + 1;  
		        			m = m < 10 ? '0' + m : m;  
		        			var d = date.getDate();  
		        			d = d < 10 ? ('0' + d) : d;  
		        			var needDate=y + '-' + m + '-' + d;  
		        			var dlzh=$("#tontyiStaffId").html();
		        			
		        			$.ajax({
				                type: "Post",
				                url: "to_idToTbstaff",
				                data: {staffNo:dlzh},
				                success: function (data) {
				                	$("#bgchargeProcess").textbox("setText",data[0].staffName);
				                }
				            });
		        			
		                	$("#bgchargeicName").textbox("setText",data.iName);
		                	$("#bgchargeicSex").textbox("setText",data.iSex);
		                	$("#bgchargeDate").textbox("setText",needDate);
		                	var tolmoney=0;
		                	$.ajax({
                                url: "to_JlRecipePay",
                                data: {irpId:value},
                                success: function (data) {                               	
                                	for(var i in data) {
                                		tolmoney=tolmoney+data[i].rpNum 
                                		$("#bgchargeShouldMoney").textbox("setText",tolmoney);
                                	}  
                                	$.ajax({
                                        type: "Post",
                                        url: "to_JlCheckPay",
                                        data: {irpId:value},
                                        success: function (data) {
                                        	for(var i in data) {
                                        	tolmoney=tolmoney+data[i].cpNum 
                                        	$("#bgchargeShouldMoney").textbox("setText",tolmoney);
                                        }}
                                    });
                                }
                            });
		                	                			                		
		                }
		            });
		        			        	   
		        },		    
		    }
		});
		
		$.extend($.fn.validatebox.defaults.rules, {
			TrueMoney: {
		        validator: function(value){
		        	var ShoulMoney= $("#bgchargeShouldMoney").textbox("getText");
		        	var TrueMoney= $("#bgchargeTrueMoney").textbox("getText");		        	
		        	var repair=TrueMoney-ShoulMoney;
		        		$("#bgchargeBackMoney").textbox("setText",repair);		        			       			        	   
		        },
		    }
		});
		
		$(function(){			
			
			$('#tt').tabs({    
			    border:true,    
			    onSelect:function(title){    
			       if(title=="检查缴费表"){
			    	    $('#bg_charge_ApplyWin').window({'title': "检查详情"});
						$("#bg_charge_ApplyWin").window('open');
						
			       } else if(title=="处方缴费表") {
			    	   
			       }  
			    }    
			}); 
			
			$("#charge_wancheng").linkbutton({
				onClick:function(){	
					var eDate = rows[0].eDate;
			        var date = new Date(eDate);		
					var y = date.getFullYear();  
					var m = date.getMonth() + 1;  
					m = m < 10 ? '0' + m : m;  
					var d = date.getDate();  
					d = d < 10 ? ('0' + d) : d;  
					var needDate=y + '-' + m + '-' + d;	
					var icid=$("#bgchargeic").textbox("getText")
					$.ajax({
                        type: "Post",
                        url: "to_addJlRecipe2",
                        data: {
                            	   irpId:icid, 
                            	   rpDate:needDate,
                            	   rpFigurePerson :$("#bgchargeProcess").textbox("getText"),
                            	   rpNum :120,
                            	   rrpId:'完成'
                        	  },					
                        success: function (data) {
                            
                        }
                    });
					$.ajax({
                        type: "Post",
                        url: "to_addJlCheckPaypage",
                        data: {
		                        cpFigurePerson:$("#bgchargeProcess").textbox("getText"), 
		                        cpDate:needDate,
		                        cpNum:120,
		                        icpId:icid,
		                        pccpId:'完成'                            	                             	                            	   
                        	  },					
                        success: function (data) {
                            
                        }
                    });
										
				}
			});
			
			$("#charge_huajia").linkbutton({
				onClick:function(){	
					var bgCharge_money_money=$("#bgchargeShouldMoney").textbox("getText");
					if(bgCharge_money_money==null || bgCharge_money_money==""){
						 $.messager.alert("温馨提示", "无缴费项");
					}else{
						$("#bgCharge_money_win").window({'title': "划价操作"});
						$("#bgCharge_money_win").window('open');
					}										
				}
			});
			
			$("#bgCharge_huajia_cancel").linkbutton({
				onClick:function(){	
					$("#bgCharge_money_win").window('close');				
				}
			});
			
	});
		$("#bgCharge_huajia_save").linkbutton({
			onClick:function(){	
				var bgCharge_money_money=$("#bgchargeShouldMoney").textbox("getText");
				var backShouldMoney=parseFloat(bgCharge_money_money);
				var backInfo="";
				var sb=$("#bgCharge_money_sb").textbox("getText");
				var yb=$("#bgCharge_money_yb").textbox("getText");
				var hy=$("#bgCharge_money_hy").textbox("getText");
				var jz=$("#bgCharge_money_jz").textbox("getText");	
				if(sb!=""){
					backShouldMoney=backShouldMoney*0.8;
					backInfo=backInfo+"社保服务"
				}else if(yb!=""){
					backShouldMoney=backShouldMoney*0.7;
					backInfo=backInfo+"医保服务"
				}else if(hy!=""){
					backShouldMoney=backShouldMoney*0.9;
					backInfo=backInfo+"会员服务"
				}else if(jz!=""){
					backShouldMoney=backShouldMoney*0.6;
					backInfo=backInfo+"救济服务"
				}
				$("#bgchargeShouldMoney").textbox("setText",backShouldMoney+"("+backInfo+")");																																					
			}
		});
																		
	</script>
	
	<div id="p" class="easyui-panel" title="收费管理" style="width:100%;height:96.9%;padding:10px;background:#fafafa;"   
        data-options="iconCls:'icon-save'
    ">  
    	<div id="bgcharge_btn" style="border:1px solid #95B8E7;padding-top:12px;overflow: auto;">
    		<div style="border:1px solid #95B8E7;float:left;margin-left:10px;border-top-left-radius:5px;border-top-right-radius:5px;border-bottom-right-radius:5px; border-bottom-left-radius:5px;">
			<a id="charge_huajia" class="easyui-linkbutton"
				data-options="iconCls:'icon-add',plain:true">划价操作
			</a> 
			</div>
			<div style="border:1px solid #95B8E7;float:left;margin-left:10px;border-top-left-radius:5px;border-top-right-radius:5px;border-bottom-right-radius:5px; border-bottom-left-radius:5px;">
			<a id="charge_wancheng" class="easyui-linkbutton"
				data-options="iconCls:'icon-add',plain:true">完成收费
			</a> 
			</div>			
	 	</div> 
        <div>
	    	<form id="bgchargeff" action="" method="post">
					<table>
						<tr>
							<td>
								<div class="item">
									<input id="bgchargeic"  class="easyui-textbox" data-options="label: '卡号:', width: 200,validType: ['ChackIc'],labelWidth:65">
								</div>
							</td>
							<td>
								<div class="item">
									<input id="bgchargeicName"   class="easyui-textbox" data-options="label: '姓名:', width: 200,labelWidth:65">
								</div>
							</td>							
							<td>
								<div class="item">
									<input id="bgchargeProcess"   class="easyui-textbox" data-options="label: '处理人:', width: 200,labelWidth:65">
								</div>
							</td>
							<td>
								<div class="item">
									<input id="bgchargeDate"   class="easyui-textbox" data-options="label: '日期:', width: 200,labelWidth:65">
								</div>
							</td>
						</tr>
						
						<tr>
							<td>
								<div class="item">
									<input id="bgchargeShouldMoney"   class="easyui-textbox" data-options="label: '应收金额:', width: 200,labelWidth:65">
								</div>
							</td>
							<td>
								<div class="item">
									<input id="bgchargeTrueMoney"   class="easyui-textbox" data-options="label: '实收金额:',validType: ['TrueMoney'], width: 200,labelWidth:65">	
								</div>
							</td>
							<td>
								<div class="item">
									<input id="bgchargeBackMoney"   class="easyui-textbox" data-options="label: '应退金额:', width: 200,labelWidth:65">	
								</div>
							</td>
							
						</tr>
					</table>	
			 </form>
			 <div id="tt" class="easyui-tabs" style="width:100%;height:305px;">   
				    <div title="处方缴费表" style="display:none;">   
				        	<table id="bg_charge_tab" class="easyui-datagrid"
								data-options="
									fitColumns:true,
									fit:true,
									border:true,
									rownumbers: true,
								    url: 'to_JlRecipePayByPage',								
									pagination:true,						
									pageSize: 7,
									pageList:[7,14,21,28]
								">
								<thead>
									<tr>
										<th class="ident" data-options="field:'rpId',checkbox:true">编号</th>
										<th class="ident" data-options="field:'rpFigurePerson',width:10">处理人</th>
										<th class="ident" data-options="field:'rpNum',width:15,editor:'textbox'">缴费额</th>
										<th class="ident" data-options="field:'irpId'">卡号</th>									
										<th class="ident" data-options="field:'rpDate',width:10,formatter:function(value){
					                          var unixTimestamp = new Date(value);  
					                          return unixTimestamp.toLocaleDateString();}">缴费日期
					                    </th> 
										<th class="ident" data-options="field:'rrpId'">详情</th>						                    
									</tr>
								</thead>
							</table>	    
				    </div>   
				    <div title="检查缴费表" data-options="closable:true" style="overflow:auto;display:none;">   
				       		<table id="bg_charge_tab" class="easyui-datagrid"
								data-options="
									fitColumns:true,
									fit:true,
									border:true,
									rownumbers: true,
								    url: 'to_JlCheckPaypage',								
									pagination:true,						
									pageSize: 7,
									pageList:[7,14,21,28]
								">
								<thead>
									<tr>
										<th class="ident" data-options="field:'cpId',checkbox:true">编号</th>
										<th class="ident" data-options="field:'cpFigurePerson',width:10">处理人</th>
										<th class="ident" data-options="field:'cpNum',width:15,editor:'textbox'">缴费额</th>
										<th class="ident" data-options="field:'icpId'">卡号</th>									
										<th class="ident" data-options="field:'cpDate',width:10,formatter:function(value){
					                          var unixTimestamp = new Date(value);  
					                          return unixTimestamp.toLocaleDateString();}">缴费日期
					                    </th> 
										<th class="ident" data-options="field:'pccpId'">详情</th>						                    
									</tr>
								</thead>
							</table>				       		  
				    </div>   
				     
			</div> 			   
	    </div> 	
	     
	</div>
	
	<div id="bgCharge_money_win" class="easyui-window"
			style="padding: 10px;line-height: 150%;"
			data-options="
		     width: 450,
		     height:204,
		     closed: true,
		     title:'学生信息操作'
			">		
					<table>
						<tr>
							<td>
								<div class="item">
									<input id="bgCharge_money_sb"   class="easyui-textbox" data-options="label: '社会保障卡',validType: ['huajia'], width: 200,labelWidth:65">
								</div>
							</td>
							<td>
								<div class="item">
									<input id="bgCharge_money_yb"   class="easyui-textbox"  data-options="label: '医疗保险卡',validType: ['huajia'], width: 200,labelWidth:65">
								</div>
							</td>
						</tr>	
						<tr>
							<td>
								<div class="item">
									<input id="bgCharge_money_hy"   class="easyui-textbox" data-options="label: 'vip会员卡',validType: ['huajia'], width: 200,labelWidth:65">
								</div>
							</td>
							<td>
								<div class="item">
									<input id="bgCharge_money_jz"   class="easyui-textbox"  data-options="label: '医疗救助卡',validType: ['huajia'], width: 200,labelWidth:65">
								</div>
							</td>
						</tr>							
						<tr>
							<td>
								<div class="item">
									<a id="bgCharge_huajia_save" class="easyui-linkbutton">确定</a>
								</div>
							</td>
							<td>
								<div class="item">
									<a id="bgCharge_huajia_cancel" class="easyui-linkbutton">取消</a>
								</div>
							</td>
						</tr>
					</table>							
		</div>
</body>
</html>